<template>
  <div class="">
    <van-card
      v-for="(item, index) in result"
      :key="index"
      :title="item.title"
      :thumb="item.img"
      @click="gotodetail(item)"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      keywords: this.$route.query.keywords,
      result: [],
    };
  },
  mounted() {
    this.$axios.get("list.json").then((res) => {
      this.result = res.data.list.filter((item) => {
        return item.title.includes(this.keywords);
      });
    });
  },
  methods: {
    gotodetail(item) {
      console.log(item);
      this.$router.push({ path: "/detail", query: { item: item } });
    },
  },
  components: {},
};
</script>

<style lang="scss"></style>
